{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "orig_nbformat": 4,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.3 64-bit ('ml2': pyenv)"
  },
  "interpreter": {
   "hash": "8caa4319d59a734f94e739df6b594acde678ec5f2e3eb7152d087fc4a1992669"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# SYNTCOMP Preprocessing"
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "from ml2.ltl import LTLSpecData\n",
    "from ml2.tools.bosy.tlsf_to_bosy import tlsf_to_bosy"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "DATA_DIR = ''"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "# convert tlsf to BoSy input format\n",
    "tlsf_to_bosy(DATA_DIR, DATA_DIR)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "INPUTS = ['i0', 'i1', 'i2', 'i3', 'i4']\n",
    "OUTPUTS = ['o0', 'o1', 'o2', 'o3', 'o4']\n",
    "\n",
    "# construct filtered BoSy input dataset\n",
    "def filter(spec):\n",
    "    return len(spec.inputs) <= len(INPUTS) and len(spec.outputs) <= len(OUTPUTS)\n",
    "\n",
    "data = LTLSpecData.from_bosy_files(DATA_DIR, filter)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "# rename atomic propositions\n",
    "data.rename_aps(INPUTS, OUTPUTS)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "# save dataset\n",
    "data.save('sc-1', upload=False, add_to_wandb=False)"
   ],
   "outputs": [],
   "metadata": {}
  }
 ]
}